/*
 * Created by 岱青海蓝信息系统(北京)有限公司 on 17-2-17 下午5:16
 * Copyright (c) 2017. All rights reserved.
 */

package com.example.dqhl.recycleviewdemo.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.dqhl.recycleviewdemo.R;

import java.util.List;

/**
 * Created by dqhl on 17/2/17.
 */
public class CoordinatorAdapter extends RecyclerView.Adapter<CoordinatorAdapter.MyViewHolder> {

    private Context mContext;
    private List<String> stringList;

    public CoordinatorAdapter(Context context, List<String> stringList) {
        this.mContext = context;
        this.stringList = stringList;
    }
    @Override
    public CoordinatorAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        MyViewHolder holder = new MyViewHolder(LayoutInflater.from(
                mContext).inflate(R.layout.item_main, parent, false));
        return holder;
    }

    @Override
    public void onBindViewHolder(CoordinatorAdapter.MyViewHolder holder, int position) {
        holder.tv.setText(stringList.get(position)+"猴子傻吊");
    }

    @Override
    public int getItemCount() {
        return stringList.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder {
        TextView tv;

        public MyViewHolder(View view) {
            super(view);
            tv = (TextView) view.findViewById(R.id.tv_num);
        }
    }
}
